var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2GameUser = require("GameUser");
var $2UIManager = require("UIManager");
var $2Platformconf = require("Platformconf");
var $2UIVMain = require("UIVMain");
var $2ccUtil = require("ccUtil");
var $2GameConfiguration = require("GameConfiguration");
var $2Globe = require("Globe");
var $2levelbase = require("levelbase");
var $2gezi_2 = require("gezi_2");
var $2level_yuan = require("level_yuan");
var Adv_skd=require("./Adv_skd")
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var m;
var f;
var y;
var b;
(function (t) {
  t[t.qiangs = 0] = "qiangs";
  t[t.qius = 1] = "qius";
  t[t.qiang1 = 2] = "qiang1";
  t[t.qiang2 = 3] = "qiang2";
  t[t.childs = 4] = "childs";
  t[t.childs_r = 5] = "childs_r";
  t[t.childs_eff = 6] = "childs_eff";
  t[t.move_wall = 7] = "move_wall";
  t[t.max = 8] = "max";
})(m || (m = {}));
(function (t) {
  t[t.ridgebody = 0] = "ridgebody";
  t[t.gezi_a = 1] = "gezi_a";
  t[t.gezi_b = 2] = "gezi_b";
  t[t.gezi_c = 3] = "gezi_c";
  t[t.gezi_d = 4] = "gezi_d";
  t[t.yuan1 = 5] = "yuan1";
  t[t.yuan2 = 6] = "yuan2";
  t[t.yuan3 = 7] = "yuan3";
  t[t.max = 8] = "max";
})(f || (f = {}));
(function (t) {
  t[t.man = 0] = "man";
  t[t.max = 1] = "max";
})(y || (y = {}));
(function (t) {
  t[t["螺丝钉"] = 0] = "螺丝钉";
  t[t.max = 1] = "max";
})(b || (b = {}));
var def_level_game_2 = /* */function (_d$default) {
  function _ctor() {
    var _this4;
    babel_classCallCheck(this, _ctor);
    _this4 = _callSuper(this, _ctor, arguments);
    _this4.SceneArrs = [];
    _this4.SpineArrs = [];
    _this4.ArrPres = [];
    _this4.qiuNum = null;
    _this4.jingdu = null;
    _this4.title = [];
    _this4.skin_spine = [];
    _this4.max_qiu = 0;
    _this4.qius = [];
    _this4.CanMoveNodeArrs = [];
    _this4.geziData = [];
    _this4.childs = null;
    _this4.childs_r = null;
    _this4.childs_eff = null;
    _this4.speed_q1 = 5;
    _this4.shitouid = "0";
    _this4.btn_bomb = null;
    _this4.isget30s = false;
    _this4.zhadan = null;
    _this4.bombani = null;
    _this4.item_wid = 65;
    _this4.item_hig = 65;
    _this4.map_Width = 11;
    _this4.map_Hight = 10;
    _this4.map_Data = [];
    _this4.skin_cfg1 = [6, 6, 6, 6, 6, 6];
    _this4.curr_skin = "0";
    _this4.curr_rand = 0;
    _this4.finger = null;
    _this4.initPos = null;
    _this4.startClickTime = 0;
    _this4.curr_nd = null;
    _this4.curr_pos = cc.v2(0, 0);
    _this4.new_nd = null;
    _this4.arr_neibor = [null, null, null, null];
    _this4.cantouch = false;
    _this4.deleteNds = [];
    _this4.IsGameOver = false;
    _this4.isStartChange = false;
    _this4.gameTime = 0;
    _this4.moveWay = -1;
    _this4.need_score = 0;
    _this4.need_last = 0;
    _this4.curr_score = 0;
    _this4.speed = .082;
    _this4.is_shan = false;
    _this4.pauseTime = 0;
    return _this4;
  }
  babel_inherits(_ctor, _d$default);
  return babel_createClass(_ctor, [{
    key: "btn",
    value: function btn(t, e) {
      var _this5 = this;
      var i = t.getCurrentTarget();
      if ("btn_bomb" == i.name) {
        if ($2GameUser.default.getInstance().bomb) {
          $2GameUser.default.getInstance().bomb = false;
          this.btn_bomb.getChildByName("1").active = false;
          this.btn_bomb.getChildByName("video").active = true;
          var _t = false;
          var _e = null;
          var _i = 0;
          for (var _s = 0; _s < this.geziData.length; _s++) {
            var _n = this.geziData[_s].length;
            for (var _a = 0; _a < _n; _a++) {
              if (_a >= 8 && _a <= 10 && -1 != this.geziData[_s][_a][0]) {
                var _n2 = this.geziData[_s][_a][1];
                var _r = this.CanMoveNodeArrs[_n2];
                if (!_t) {
                  _t = true;
                  _e = _r.getPosition();
                }
                _r.getComponent($2gezi_2.default).isNeedDelete || (_r.getComponent($2gezi_2.default).isNeedDelete = true);
                this.geziData[_s][_a] = [-1, -1];
                _r.removeFromParent();
                _r.parent = this.childs_eff;
                this.dobomb(_r);
                if (++_i >= 4) {
                  break;
                }
              }
            }
            if (_i >= 4) {
              break;
            }
          }
          if (null != _e) {
            this.bombani.opacity = 255;
            cc.tween(this.bombani).bezierTo(.9, cc.v2(116, 470), cc.v2(600, 470), _e).to(.1, {
              opacity: 0
            }).call(function () {
              _this5.zhadan.node.setPosition(_e);
              _this5.zhadan.node.active = true;
              _this5.zhadan.setAnimation(0, "go", false);
            }).call(function () {
              _this5.bombani.setPosition(cc.v2(116, 470));
            }).start();
          }
        } else {
          $2UIManager.UIManager.getInstance().getUI($2UIVMain.default).levelPlayAD(function () {
            $2GameUser.default.getInstance().bomb = true;
            _this5.btn_bomb.getChildByName("1").active = true;
            _this5.btn_bomb.getChildByName("video").active = false;
          });
        }
      } else {
        "btn_addTime" == i.name && $2UIManager.UIManager.getInstance().getUI($2UIVMain.default).levelPlayAD(function () {
          _this5.isget30s = true;
          _this5.scheduleOnce(function () {
            _this5.isget30s = false;
          }, 30);
        });
      }
    }
  }, {
    key: "dobomb",
    value: function dobomb(t) {
      var _this6 = this;
      this.scheduleOnce(function () {
        t.getComponent($2gezi_2.default).xiaoshi();
        _this6.jianceRidgebody();
      }, 1);
    }
  }, {
    key: "init_bomb",
    value: function init_bomb() {
      this.bombani.opacity = 0;
      if ($2Platformconf.default.PlatformType == $2Platformconf.ePlatformType.KWaiGame || cc.sys.isBrowser) {
        this.btn_bomb.active = true;
        var _t2 = $2GameUser.default.getInstance().bomb;
        this.btn_bomb.getChildByName("1").active = _t2;
        this.btn_bomb.getChildByName("video").active = !_t2;
      }
    }
  }, {
    key: "onDisable",
    value: function onDisable() {
      babel_get(babel_getPrototypeOf(_ctor.prototype), "onDisable", this).call(this);
    }
  }, {
    key: "getsjnum",
    value: function getsjnum(t, e) {
      var i = $2Globe.default.getInstance().random(0, 2);
      if (t >= 2) {
        var _s2 = this.geziData[t - 1][e][0];
        var _n3 = this.geziData[t - 2][e][0];
        if (i == _s2 && i == _n3) {
          return this.getsjnum(t, e);
        }
      }
      if (e >= 2) {
        var _s3 = this.geziData[t][e - 1][0];
        var _n4 = this.geziData[t][e - 2][0];
        if (i == _s3 && i == _n4) {
          return this.getsjnum(t, e);
        }
      }
      return i;
    }
  }, {
    key: "onLoad",
    value: function onLoad() {
      Adv_skd.default.instance.hideBannerAd()
      Adv_skd.default.instance.hideGridAdLeftOne()
      Adv_skd.default.instance.hideGridAdRightOne()
      var _this7 = this;
      babel_get(babel_getPrototypeOf(_ctor.prototype), "onLoad", this).call(this);
      if (cc.sys.OS_IOS == cc.sys.os) {
        cc.director.getPhysicsManager().enabledAccumulator = true;
        cc.PhysicsManager.FIXED_TIME_STEP = .04;
        cc.PhysicsManager.VELOCITY_ITERATIONS = 3;
        cc.PhysicsManager.POSITION_ITERATIONS = 3;
      }
      this.childs = this.SceneArrs[m.childs];
      this.childs_r = this.SceneArrs[m.childs_r];
      this.childs_eff = this.SceneArrs[m.childs_eff];
      this.shitouid = $2GameUser.default.getInstance().curr_skin_stone;
      console.log("shitou", this.shitouid);
      this.init_spine();
      this.init_bomb();
      this.scheduleOnce(function () {
        _this7.cantouch = true;
      }, 3);
    }
  }, {
    key: "init_spine",
    value: function init_spine() {
      var t = $2GameUser.default.getInstance().curr_skin_spine;
      var e = parseInt(t);
      var i = this.skin_spine[e];
      this.SpineArrs[y.man].skeletonData = i;
      this.SpineArrs[y.man].setAnimation(0, "idle", true);
    }
  }, {
    key: "start",
    value: function start() {
      var _this8 = this;
      babel_get(babel_getPrototypeOf(_ctor.prototype), "start", this).call(this);
      this.curr_skin = $2GameUser.default.getInstance().curr_skin;
      var t = "帮助国王脱困 第".concat($2GameUser.default.getInstance().PassLevelNum + 1, "关");
      this.title[0].string = t;
      this.title[1].string = t;
      if ($2UIManager.UIManager.getInstance().getUI($2UIVMain.default).currlv != $2GameUser.default.getInstance().PassLevelNum) {
        $2UIManager.UIManager.getInstance().getUI($2UIVMain.default).currlv = $2GameUser.default.getInstance().PassLevelNum;
        this.curr_rand = $2GameUser.default.getInstance().curr_rand;
        this.curr_rand += 1;
        this.curr_rand > 3 && (this.curr_rand = 0);
        $2GameUser.default.getInstance().curr_rand = this.curr_rand;
        console.log("2222", this.curr_rand);
      }
      var e = Math.floor(100 * Math.random()) % 2 == 0 ? [0, 1, 2, 0, 1, 2, 0, 1, 2, 1, 1] : [2, 2, 1, 1, 2, 2, 1, 0, 0, 2, 0];
      var i = 0;
      for (var _n5 = 0; _n5 < this.map_Hight; _n5++) {
        this.geziData[_n5] = [];
        for (var _t3 = 0; _t3 < this.map_Width; _t3++) {
          var _s4 = 0;
          if (0 == _n5) {
            _s4 = e[i];
            i++;
          } else {
            _s4 = this.getsjnum(_n5, _t3);
          }
          this.geziData[_n5][_t3] = [_s4];
        }
      }
      var s = f.gezi_a;
      if ("0" == this.curr_skin) {
        s = f.gezi_a;
      } else if ("1" == this.curr_skin) {
        s = f.gezi_b;
      } else if ("2" == this.curr_skin) {
        s = f.gezi_c;
      } else {
        "3" == this.curr_skin && (s = f.gezi_d);
      }
      var r = 0;
      for (var _n6 = 0; _n6 < this.geziData.length; _n6++) {
        for (var _t4 = 0; _t4 < this.geziData[_n6].length; _t4++) {
          var _e2 = "".concat(r);
          var _i2 = cc.instantiate(this.ArrPres[s]);
          _i2.parent = this.childs;
          _i2.setPosition(32 + this.item_wid * _t4, -32 - this.item_hig * _n6);
          _i2.name = _e2;
          var _a2 = cc.instantiate(this.ArrPres[f.ridgebody]);
          _a2.parent = this.childs_r;
          _a2.setPosition(32 + this.item_wid * _t4, -32 - this.item_hig * _n6);
          _a2.name = _e2;
          var _h = this.CanMoveNodeArrs.length;
          this.geziData[_n6][_t4][1] = _h;
          _i2.getComponent($2gezi_2.default).id = _h;
          this.CanMoveNodeArrs[this.CanMoveNodeArrs.length] = _i2;
          var _o = this.geziData[_n6][_t4][0] + this.curr_rand;
          _i2.getComponent($2gezi_2.default).setColor(_o);
          r++;
        }
      }
      this.childs.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
      this.childs.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
      this.childs.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
      this.childs.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
      this.playPublicSound("bgm", true);
      this.playPublicSound("shitou");
      this.max_qiu = $2GameConfiguration.default.getGFByType($2GameConfiguration.eGameFeatures.BlockCount, "level2");
      this.need_score = 120;
      console.log("球的数量：", this.max_qiu);
      this.scheduleOnce(function () {
        for (var _t5 = 0; _t5 < _this8.SceneArrs[m.qiangs].children.length; _t5++) {
          var _e3 = _this8.SceneArrs[m.qiangs].children[_t5];
          var _i3 = _e3.getPosition().add(cc.v2(-375, -667));
          _e3.setPosition(_i3);
        }
        _this8.schedule(function () {
          _this8.instenceqiu();
        }, 0, _this8.max_qiu - 1);
      });
      this.qiuNum.string = "消除120块石头：0/120";
      this.scheduleOnce(function () {
        _this8.isStartChange = true;
        _this8.SpineArrs[y.man].setAnimation(0, "go", true);
      }, 2);
      $2GameUser.default.getInstance().IsNewPlayer && this.newHand();
    }
  }, {
    key: "newHand",
    value: function newHand() {
      var _this9 = this;
      var t = false;
      var e = false;
      var i = cc.v2(0, 0);
      var s = this.geziData.length;
      for (var _n7 = 0; _n7 < s; _n7++) {
        var _s5 = this.geziData[_n7].length;
        console.log("this.geziData[i]", _n7);
        for (var _a3 = 0; _a3 < _s5; _a3++) {
          var _s6 = this.geziData[_n7][_a3][0];
          if (_a3 <= 7 && _s6 == this.geziData[_n7][_a3 + 1][0] && this.geziData[_n7][_a3 + 3][0] == _s6) {
            var _s7 = this.geziData[_n7][_a3 + 3][1];
            i = this.CanMoveNodeArrs[_s7].getPosition();
            e = true;
            t = true;
            break;
          }
          if (_a3 >= 3 && _s6 == this.geziData[_n7][_a3 - 1][0] && this.geziData[_n7][_a3 - 3][0] == _s6) {
            var _e4 = this.geziData[_n7][_a3 - 3][1];
            i = this.CanMoveNodeArrs[_e4].getPosition();
            t = true;
            break;
          }
        }
        if (t) {
          break;
        }
      }
      this.finger.setPosition(i);
      this.scheduleOnce(function () {
        _this9.finger.active = true;
        var t = e ? "ani_finger_R" : "ani_finger_L";
        _this9.finger.getComponent(cc.Animation).play(t);
      }, 1);
    }
  }, {
    key: "instenceqiu",
    value: function instenceqiu() {
      var t = Math.floor(3 * Math.random());
      var e = f.yuan1;
      var i = $2GameConfiguration.eGameFeatures.Model1Info;
      if (0 == t) {
        e = f.yuan1;
        i = $2GameConfiguration.eGameFeatures.Model1Info;
      } else if (1 == t) {
        e = f.yuan2;
        i = $2GameConfiguration.eGameFeatures.Model2Info;
      } else if (2 == t) {
        e = f.yuan3, i = $2GameConfiguration.eGameFeatures.Model3Info;
      }
      var s = cc.instantiate(this.ArrPres[e]);
      s.parent = this.SceneArrs[m.qius];
      s.getComponent(cc.PhysicsCircleCollider).radius = $2GameConfiguration.default.getGFByType(i).radius;
      s.getComponent(cc.PhysicsCircleCollider).restitution = $2GameConfiguration.default.getGFByType(i).resilient;
      s.getChildByName("shikuai").width = $2GameConfiguration.default.getGFByType(i).size;
      s.getChildByName("shikuai").height = $2GameConfiguration.default.getGFByType(i).size;
      var n = 400 * Math.random() - 200;
      var a = 80 * Math.random() - 60;
      s.setPosition(-60 + n, 550 + a);
      var r = parseInt(this.shitouid);
      s.getComponent($2level_yuan.default).init(r);
      this.qius[this.qius.length] = s;
    }
  }, {
    key: "onTouchStart",
    value: function onTouchStart(t) {
      if (!this.cantouch) {
        return;
      }
      if (this.IsGameOver) {
        return;
      }
      this.finger.active && (this.finger.active = false);
      var e = t.getLocation();
      for (var _i4 = 0; _i4 < this.childs.childrenCount; _i4++) {
        var _t6 = this.childs.children[_i4];
        var _s8 = $2ccUtil.default.getPolygon(_t6);
        if (cc.Intersection.pointInPolygon(e, _s8)) {
          this.curr_nd = _t6;
          this.curr_nd.zIndex += 100;
          this.curr_pos = _t6.getComponent($2gezi_2.default).startPos;
          _t6.getComponent($2gezi_2.default).ischoose(true);
          this.playPublicSound("xuanzhong");
          for (var _t7 = 0; _t7 < this.childs.childrenCount; _t7++) {
            var _e5 = this.childs.children[_t7];
            if (_e5 != this.curr_nd) {
              var _t8 = _e5.getPosition();
              if (Math.abs(_t8.x - this.curr_pos.x) < 5) {
                if (_t8.y - this.curr_pos.y > 60 && _t8.y - this.curr_pos.y < 70) {
                  this.arr_neibor[0] = _e5;
                } else {
                  _t8.y - this.curr_pos.y > -70 && _t8.y - this.curr_pos.y < -60 && (this.arr_neibor[3] = _e5);
                }
              }
              if (Math.abs(_t8.y - this.curr_pos.y) < 5) {
                if (_t8.x - this.curr_pos.x < -60 && _t8.x - this.curr_pos.x > -70) {
                  this.arr_neibor[1] = _e5;
                } else {
                  _t8.x - this.curr_pos.x > 60 && _t8.x - this.curr_pos.x < 70 && (this.arr_neibor[2] = _e5);
                }
              }
            }
          }
          break;
        }
      }
    }
  }, {
    key: "onTouchMove",
    value: function onTouchMove(t) {
      if (this.cantouch && !this.IsGameOver && null != this.curr_nd) {
        var _e6 = t.getLocation();
        var _i5 = this.childs.convertToNodeSpaceAR(_e6);
        var _s9 = this.curr_pos.x - _i5.x;
        var _n8 = this.curr_pos.y - _i5.y;
        if (Math.abs(_s9) < this.item_wid && Math.abs(_n8) < this.item_hig) {
          if (Math.abs(_s9) > Math.abs(_n8)) {
            if (_i5.x > 32 && _i5.x < 682) {
              var _t9 = _i5.x;
              if (null == this.arr_neibor[1]) {
                _i5.x < this.curr_pos.x && (_t9 = this.curr_pos.x);
              } else {
                var _t10 = this.curr_nd.x - this.curr_pos.x;
                if (_t10 < 0) {
                  this.arr_neibor[1].opacity = 200 + 55 * (1 - Math.abs(_s9) / this.item_wid);
                  this.arr_neibor[1].getChildByName("baoshi").x = -_t10;
                } else {
                  this.arr_neibor[1].getChildByName("baoshi").x = 0;
                }
              }
              if (null == this.arr_neibor[2]) {
                _i5.x > this.curr_pos.x && (_t9 = this.curr_pos.x);
              } else {
                var _t11 = this.curr_nd.x - this.curr_pos.x;
                if (_t11 > 0) {
                  this.arr_neibor[2].opacity = 200 + 55 * (1 - Math.abs(_s9) / this.item_wid);
                  this.arr_neibor[2].getChildByName("baoshi").x = -_t11;
                } else {
                  this.arr_neibor[2].getChildByName("baoshi").x = 0;
                }
              }
              this.curr_nd.x = _t9;
              this.curr_nd.y = this.curr_pos.y;
            }
          } else if (_i5.y < -32 && _i5.y > -617) {
            var _t12 = _i5.y;
            if (null == this.arr_neibor[0]) {
              _i5.y > this.curr_pos.y && (_t12 = this.curr_pos.y);
            } else {
              var _t13 = this.curr_nd.y - this.curr_pos.y;
              if (_t13 > 0) {
                this.arr_neibor[0].opacity = 200 + 55 * (1 - Math.abs(_n8) / this.item_hig);
                this.arr_neibor[0].getChildByName("baoshi").y = -_t13;
              } else {
                this.arr_neibor[0].getChildByName("baoshi").y = 0;
              }
            }
            if (null == this.arr_neibor[3]) {
              _i5.y < this.curr_pos.y && (_t12 = this.curr_pos.y);
            } else {
              var _t14 = this.curr_nd.y - this.curr_pos.y;
              if (_t14 < 0) {
                this.arr_neibor[3].opacity = 200 + 55 * (1 - Math.abs(_n8) / this.item_hig);
                this.arr_neibor[3].getChildByName("baoshi").y = -_t14;
              } else {
                this.arr_neibor[3].getChildByName("baoshi").y = 0;
              }
            }
            this.curr_nd.y = _t12;
            this.curr_nd.x = this.curr_pos.x;
          }
        }
      }
    }
  }, {
    key: "log_name",
    value: function log_name(t) {}
  }, {
    key: "onTouchEnd",
    value: function onTouchEnd(t) {
      if (this.cantouch && !this.IsGameOver && null != this.curr_nd) {
        for (var _t15 = 0; _t15 < this.childs.childrenCount; _t15++) {
          var _e7 = this.childs.children[_t15];
          if (this.curr_nd.name != _e7.name && $2ccUtil.default.checkWorldBox(this.curr_nd, _e7)) {
            this.new_nd = _e7;
            break;
          }
        }
        if (null != this.new_nd) {
          if (this.curr_nd.getComponent($2gezi_2.default).color == this.new_nd.getComponent($2gezi_2.default).color) {
            this.reflash_curr();
          } else {
            this.swap_ndpos(this.curr_nd, this.new_nd);
            this.jiancesanlian();
          }
        } else {
          this.reflash_curr();
        }
      }
    }
  }, {
    key: "swap_ndpos",
    value: function swap_ndpos(t, e) {
      var i = t.getComponent($2gezi_2.default).startPos;
      var s = e.getComponent($2gezi_2.default).startPos;
      t.getChildByName("baoshi").setPosition(cc.v2(0, 0));
      t.setPosition(s);
      e.setPosition(i);
    }
  }, {
    key: "reflash_curr",
    value: function reflash_curr() {
      this.curr_nd.getComponent($2gezi_2.default).ischoose(false);
      this.curr_nd.getComponent($2gezi_2.default).guiwei();
      this.curr_nd.zIndex -= 100;
      this.curr_nd = null;
      this.curr_pos = cc.v2(0, 0);
      if (null != this.new_nd) {
        this.new_nd.getComponent($2gezi_2.default).guiwei();
        this.new_nd = null;
      }
      if (null != this.arr_neibor[0]) {
        this.arr_neibor[0].opacity = 255;
        this.arr_neibor[0].getChildByName("baoshi").setPosition(cc.v2(0, 0));
      }
      if (null != this.arr_neibor[1]) {
        this.arr_neibor[1].opacity = 255;
        this.arr_neibor[1].getChildByName("baoshi").setPosition(cc.v2(0, 0));
      }
      if (null != this.arr_neibor[2]) {
        this.arr_neibor[2].opacity = 255;
        this.arr_neibor[2].getChildByName("baoshi").setPosition(cc.v2(0, 0));
      }
      if (null != this.arr_neibor[3]) {
        this.arr_neibor[3].opacity = 255;
        this.arr_neibor[3].getChildByName("baoshi").setPosition(cc.v2(0, 0));
      }
      this.arr_neibor = [null, null, null, null];
    }
  }, {
    key: "jiancesanlian",
    value: function jiancesanlian() {
      var t = [];
      for (var _l = 0; _l < this.geziData.length; _l++) {
        t[_l] = [];
        for (var _e8 = 0; _e8 < this.geziData[_l].length; _e8++) {
          t[_l][_e8] = this.geziData[_l][_e8];
        }
      }
      var e = false;
      var i = this.getNdIdByNd(this.curr_nd);
      var s = this.getPosById(i);
      var n = this.getNdIdByNd(this.new_nd);
      var a = this.getPosById(n);
      var r = this.geziData[s[0]][s[1]];
      this.geziData[s[0]][s[1]] = this.geziData[a[0]][a[1]];
      this.geziData[a[0]][a[1]] = r;
      var h = this.jiances(s);
      var o = this.jiances(a);
      (h || o) && (e = true);
      if (e) {
        this.curr_nd.getComponent($2gezi_2.default).setStartPos();
        null != this.new_nd && this.new_nd.getComponent($2gezi_2.default).setStartPos();
        for (var _t16 = 0; _t16 < this.deleteNds.length; _t16++) {
          this.CanMoveNodeArrs[this.deleteNds[_t16].getComponent($2gezi_2.default).id] = null;
          this.deleteNds[_t16].removeFromParent();
          this.deleteNds[_t16].parent = this.childs_eff;
          this.deleteNds[_t16].getComponent($2gezi_2.default).xiaoshi();
          this.deleteNds.splice(_t16, 1);
          _t16--;
        }
        this.playPublicSound("xiaochu");
        this.jianceRidgebody();
        this.reflash_curr();
      } else {
        this.geziData = t;
        this.reflash_curr();
      }
    }
  }, {
    key: "jianceRidgebody",
    value: function jianceRidgebody() {
      var t = 0;
      for (var _e9 = 0; _e9 < this.geziData.length; _e9++) {
        for (var _i6 = 0; _i6 < this.geziData[_e9].length; _i6++) {
          -1 == this.geziData[_e9][_i6][0] && (this.childs_r.getChildByName("".concat(t)).active = false);
          t++;
        }
      }
    }
  }, {
    key: "jiances",
    value: function jiances(t) {
      var e = [t];
      e = this.jiancexiangtongzuoshang(t[0], t[1], e);
      e = this.jiancexiangtongyouxia(t[0], t[1], e);
      this.quchong(e);
      return this.panduansanlian(e);
    }
  }, {
    key: "quchong",
    value: function quchong(t) {
      for (var _e10 = 0; _e10 < t.length - 1; _e10++) {
        for (var _i7 = _e10 + 1; _i7 < t.length; _i7++) {
          if (t[_e10][0] == t[_i7][0] && t[_e10][1] == t[_i7][1]) {
            t.splice(_i7, 1);
            _i7--;
          }
        }
      }
    }
  }, {
    key: "jiancexiangtongzuoshang",
    value: function jiancexiangtongzuoshang(t, e, i) {
      var s = this.geziData[t][e][0];
      if (t > 0 && s == this.geziData[t - 1][e][0]) {
        return i[i.length] = [t - 1, e], this.jiancexiangtongzuoshang(t - 1, e, i);
      } else {
        if (e > 0 && s == this.geziData[t][e - 1][0]) {
          return i[i.length] = [t, e - 1], this.jiancexiangtongzuoshang(t, e - 1, i);
        } else {
          return i;
        }
      }
    }
  }, {
    key: "jiancexiangtongyouxia",
    value: function jiancexiangtongyouxia(t, e, i) {
      var s = this.geziData[t][e][0];
      if (t < this.map_Hight - 1 && s == this.geziData[t + 1][e][0]) {
        return i[i.length] = [t + 1, e], this.jiancexiangtongzuoshang(t + 1, e, i);
      } else {
        if (e < this.map_Width - 1 && s == this.geziData[t][e + 1][0]) {
          return i[i.length] = [t, e + 1], this.jiancexiangtongzuoshang(t, e + 1, i);
        } else {
          return i;
        }
      }
    }
  }, {
    key: "jiancexiangtongzuo",
    value: function jiancexiangtongzuo(t, e, i) {
      var s = this.geziData[t][e][0];
      if (e > 0 && s == this.geziData[t][e - 1][0]) {
        var _s10 = [t, e - 1];
        var _n9 = false;
        for (var _t17 = 0; _t17 < i.length; _t17++) {
          i[_t17][0] == _s10[0] && i[_t17][1] == _s10[1] && (_n9 = true);
        }
        _n9 || (i[i.length] = _s10);
        return this.jiancexiangtongzuo(t, e - 1, i);
      }
      return i;
    }
  }, {
    key: "jiancexiangtongshang",
    value: function jiancexiangtongshang(t, e, i) {
      var s = this.geziData[t][e][0];
      if (t > 0 && s == this.geziData[t - 1][e][0]) {
        var _s11 = [t - 1, e];
        var _n10 = false;
        for (var _t18 = 0; _t18 < i.length; _t18++) {
          i[_t18][0] == _s11[0] && i[_t18][1] == _s11[1] && (_n10 = true);
        }
        _n10 || (i[i.length] = _s11);
        return this.jiancexiangtongshang(t - 1, e, i);
      }
      return i;
    }
  }, {
    key: "jiancexiangtongyou",
    value: function jiancexiangtongyou(t, e, i) {
      var s = this.geziData[t][e][0];
      if (e < this.map_Width - 1 && s == this.geziData[t][e + 1][0]) {
        var _s12 = [t, e + 1];
        var _n11 = false;
        for (var _t19 = 0; _t19 < i.length; _t19++) {
          i[_t19][0] == _s12[0] && i[_t19][1] == _s12[1] && (_n11 = true);
        }
        _n11 || (i[i.length] = _s12);
        return this.jiancexiangtongyou(t, e + 1, i);
      }
      return i;
    }
  }, {
    key: "jiancexiangtongxia",
    value: function jiancexiangtongxia(t, e, i) {
      var s = this.geziData[t][e][0];
      if (t < this.map_Hight - 1 && s == this.geziData[t + 1][e][0]) {
        var _s13 = [t + 1, e];
        var _n12 = false;
        for (var _t20 = 0; _t20 < i.length; _t20++) {
          i[_t20][0] == _s13[0] && i[_t20][1] == _s13[1] && (_n12 = true);
        }
        _n12 || (i[i.length] = _s13);
        return this.jiancexiangtongxia(t + 1, e, i);
      }
      return i;
    }
  }, {
    key: "panduansanlian",
    value: function panduansanlian(t) {
      var e = false;
      for (var _i8 = 0; _i8 < t.length; _i8++) {
        var _s14 = [t[_i8]];
        _s14 = this.jiancexiangtongzuo(t[_i8][0], t[_i8][1], _s14);
        _s14 = this.jiancexiangtongyou(t[_i8][0], t[_i8][1], _s14);
        var _n13 = [t[_i8]];
        _n13 = this.jiancexiangtongshang(t[_i8][0], t[_i8][1], _n13);
        _n13 = this.jiancexiangtongxia(t[_i8][0], t[_i8][1], _n13);
        this.quchong(_s14);
        this.quchong(_n13);
        if (_s14.length > 2) {
          e = true;
          for (var _t21 = 0; _t21 < _s14.length; _t21++) {
            var _e11 = this.geziData[_s14[_t21][0]][_s14[_t21][1]][1];
            if (-1 != _e11) {
              var _i9 = this.CanMoveNodeArrs[_e11];
              if (!_i9.getComponent($2gezi_2.default).isNeedDelete) {
                _i9.getComponent($2gezi_2.default).isNeedDelete = true;
                this.deleteNds[this.deleteNds.length] = _i9;
                this.geziData[_s14[_t21][0]][_s14[_t21][1]] = [-1, -1];
              }
            }
          }
        }
        if (_n13.length > 2) {
          e = true;
          for (var _t22 = 0; _t22 < _n13.length; _t22++) {
            var _e12 = this.geziData[_n13[_t22][0]][_n13[_t22][1]][1];
            if (-1 != _e12) {
              var _i10 = this.CanMoveNodeArrs[_e12];
              if (!_i10.getComponent($2gezi_2.default).isNeedDelete) {
                _i10.getComponent($2gezi_2.default).isNeedDelete = true;
                this.deleteNds[this.deleteNds.length] = _i10;
                this.geziData[_n13[_t22][0]][_n13[_t22][1]] = [-1, -1];
              }
            }
          }
        }
      }
      return e;
    }
  }, {
    key: "levelUpdate",
    value: function levelUpdate(t) {
      babel_get(babel_getPrototypeOf(_ctor.prototype), "levelUpdate", this).call(this, t);
      if (this.isStartChange) {
        this.gameTime += t;
        if (this.gameTime >= .016) {
          this.gameTime -= .016, this.pauseTime <= 0 ? this.changepos() : this.pauseTime -= t, this.jianceqius();
        }
      }
    }
  }, {
    key: "getNdIdByNd",
    value: function getNdIdByNd(t) {
      for (var _e13 = 0; _e13 < this.CanMoveNodeArrs.length; _e13++) {
        if (t == this.CanMoveNodeArrs[_e13]) {
          return _e13;
        }
      }
      return -1;
    }
  }, {
    key: "getPosById",
    value: function getPosById(t) {
      for (var _e14 = 0; _e14 < this.geziData.length; _e14++) {
        for (var _i11 = 0; _i11 < this.geziData[_e14].length; _i11++) {
          if (this.geziData[_e14][_i11][1] == t) {
            return [_e14, _i11];
          }
        }
      }
      return [-1, -1];
    }
  }, {
    key: "getNdByIdAndWay",
    value: function getNdByIdAndWay(t) {
      var e = this.getNdIdByNd(t);
      var i = null;
      if (-1 == e) {
        console.log("error");
      } else {
        var _t23 = this.getPosById(e);
        var _s15 = -1;
        switch (this.moveWay) {
          case 0:
            _t23[0] > 0 && (_s15 = this.geziData[_t23[0] - 1][_t23[1]][1]);
            break;
          case 1:
            _t23[0] < 9 && (_s15 = this.geziData[_t23[0] + 1][_t23[1]][1]);
            break;
          case 2:
            _t23[1] > 0 && (_s15 = this.geziData[_t23[0]][_t23[1] - 1][1]);
            break;
          case 3:
            _t23[1] < 10 && (_s15 = this.geziData[_t23[0]][_t23[1] + 1][1]);
        }
        -1 != _s15 && (i = this.CanMoveNodeArrs[_s15]);
      }
      return i;
    }
  }, {
    key: "jianceqius",
    value: function jianceqius() {
      var _this10 = this;
      for (var _e15 = 0; _e15 < this.qius.length; _e15++) {
        if (this.qius[_e15].getPosition().y < -700) {
          this.qius[_e15].destroy();
          this.qius[_e15].removeFromParent();
          this.qius.splice(_e15, 1);
          _e15--;
          this.curr_score++;
        }
      }
      this.curr_score >= this.need_score && (this.IsGameOver || (this.IsGameOver = true, this.isStartChange = false, this.playPublicSound("zhengque"), this.SpineArrs[y.man].setAnimation(0, "idle", true), this.node.getChildByName("hong").getComponent(cc.Animation).stop(), this.scheduleOnce(function () {
        _this10.complete();
      }, 2)));
      this.qiuNum.string = "消除".concat(this.need_score, "块石头：").concat(this.curr_score, "/").concat(this.need_score);
      var t = this.curr_score / this.need_score;
      this.jingdu.fillRange = t;
      $2Globe.default.getInstance().currlv_range = t;
    }
  }, {
    key: "changepos",
    value: function changepos() {
      var _this11 = this;
      var t = this.SceneArrs[m.qiang1].getPosition();
      var e = this.SceneArrs[m.qiang2].getPosition();
      var i = this.SceneArrs[m.move_wall].getPosition();
      if (e.x < -233 && !this.is_shan) {
        this.is_shan = true;
        this.node.getChildByName("hong").getComponent(cc.Animation).play();
      }
      if (e.x < -287) {
        if (!this.IsGameOver) {
          this.IsGameOver = true, this.isStartChange = false, this.SpineArrs[y.man].setAnimation(0, "fail", false), this.playPublicSound("jianjiaonan"), this.scheduleOnce(function () {
            _this11.gamefail();
          }, 1.5);
        }
      } else {
        t.x += this.speed;
        this.SceneArrs[m.qiang1].setPosition(t);
        i.x += this.speed;
        this.SceneArrs[m.move_wall].setPosition(i);
        e.x -= this.speed;
        this.SceneArrs[m.qiang2].setPosition(e);
      }
    }
  }, {
    key: "useProp",
    value: function useProp(t) {
      var _this12 = this;
      if ("bomb" == t) {
        var _t24 = false;
        var _e16 = null;
        var _i12 = 0;
        for (var _s16 = 0; _s16 < this.geziData.length; _s16++) {
          var _n14 = this.geziData[_s16].length;
          for (var _a4 = 0; _a4 < _n14; _a4++) {
            if (_a4 >= 8 && _a4 <= 10 && -1 != this.geziData[_s16][_a4][0]) {
              var _n15 = this.geziData[_s16][_a4][1];
              var _r2 = this.CanMoveNodeArrs[_n15];
              if (!_t24) {
                _t24 = true;
                _e16 = _r2.getPosition();
              }
              _r2.getComponent($2gezi_2.default).isNeedDelete || (_r2.getComponent($2gezi_2.default).isNeedDelete = true);
              this.geziData[_s16][_a4] = [-1, -1];
              _r2.removeFromParent();
              _r2.parent = this.childs_eff;
              this.dobomb(_r2);
              if (++_i12 >= 4) {
                break;
              }
            }
          }
          if (_i12 >= 4) {
            break;
          }
        }
        if (null != _e16) {
          this.bombani.opacity = 255;
          cc.tween(this.bombani).bezierTo(.9, cc.v2(116, 470), cc.v2(600, 470), _e16).to(.1, {
            opacity: 0
          }).call(function () {
            _this12.zhadan.node.setPosition(_e16);
            _this12.zhadan.node.active = true;
            _this12.zhadan.setAnimation(0, "go", false);
          }).call(function () {
            _this12.bombani.setPosition(cc.v2(116, 470));
          }).start();
        }
      } else if ("addtime" == t) {
        this.pauseTime < 0 && (this.pauseTime = 0);
        this.pauseTime += 30;
      }
    }
  }]);
}($2levelbase.default);
cc__decorate([ccp_property(Array(cc.Node))], def_level_game_2.prototype, "SceneArrs", undefined);
cc__decorate([ccp_property(Array(sp.Skeleton))], def_level_game_2.prototype, "SpineArrs", undefined);
cc__decorate([ccp_property(Array(cc.Prefab))], def_level_game_2.prototype, "ArrPres", undefined);
cc__decorate([ccp_property(cc.Label)], def_level_game_2.prototype, "qiuNum", undefined);
cc__decorate([ccp_property(cc.Sprite)], def_level_game_2.prototype, "jingdu", undefined);
cc__decorate([ccp_property(cc.Label)], def_level_game_2.prototype, "title", undefined);
cc__decorate([ccp_property(sp.SkeletonData)], def_level_game_2.prototype, "skin_spine", undefined);
cc__decorate([ccp_property(cc.Node)], def_level_game_2.prototype, "btn_bomb", undefined);
cc__decorate([ccp_property(sp.Skeleton)], def_level_game_2.prototype, "zhadan", undefined);
cc__decorate([ccp_property(cc.Node)], def_level_game_2.prototype, "bombani", undefined);
cc__decorate([ccp_property(cc.Node)], def_level_game_2.prototype, "finger", undefined);
def_level_game_2 = cc__decorate([ccp_ccclass], def_level_game_2);
exports.default = def_level_game_2;